<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Uploaded Files and Upload Handlers &mdash; Django 1.7.8.dev20150401230226 documentation</title>
    
    <link rel="stylesheet" href="../../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../../',
        VERSION:     '1.7.8.dev20150401230226',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../_static/doctools.js"></script>
    <link rel="top" title="Django 1.7.8.dev20150401230226 documentation" href="../../index.html" />
    <link rel="up" title="File handling" href="index.html" />
    <link rel="next" title="Forms" href="../forms/index.html" />
    <link rel="prev" title="File storage API" href="storage.html" />



 
<script type="text/javascript" src="../../templatebuiltins.js"></script>
<script type="text/javascript">
(function($) {
    if (!django_template_builtins) {
       // templatebuiltins.js missing, do nothing.
       return;
    }
    $(document).ready(function() {
        // Hyperlink Django template tags and filters
        var base = "../templates/builtins.html";
        if (base == "#") {
            // Special case for builtins.html itself
            base = "";
        }
        // Tags are keywords, class '.k'
        $("div.highlight\\-html\\+django span.k").each(function(i, elem) {
             var tagname = $(elem).text();
             if ($.inArray(tagname, django_template_builtins.ttags) != -1) {
                 var fragment = tagname.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + tagname + "</a>");
             }
        });
        // Filters are functions, class '.nf'
        $("div.highlight\\-html\\+django span.nf").each(function(i, elem) {
             var filtername = $(elem).text();
             if ($.inArray(filtername, django_template_builtins.tfilters) != -1) {
                 var fragment = filtername.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + filtername + "</a>");
             }
        });
    });
})(jQuery);
</script>


  </head>
  <body>

    <div class="document">
  <div id="custom-doc" class="yui-t6">
    <div id="hd">
      <h1><a href="../../index.html">Django 1.7.8.dev20150401230226 documentation</a></h1>
      <div id="global-nav">
        <a title="Home page" href="../../index.html">Home</a>  |
        <a title="Table of contents" href="../../contents.html">Table of contents</a>  |
        <a title="Global index" href="../../genindex.html">Index</a>  |
        <a title="Module index" href="../../py-modindex.html">Modules</a>
      </div>
      <div class="nav">
    &laquo; <a href="storage.html" title="File storage API">previous</a>
     |
    <a href="../index.html" title="API Reference" accesskey="U">up</a>
   |
    <a href="../forms/index.html" title="Forms">next</a> &raquo;</div>
    </div>

    <div id="bd">
      <div id="yui-main">
        <div class="yui-b">
          <div class="yui-g" id="ref-files-uploads">
            
  <div class="section" id="s-module-django.core.files.uploadedfile">
<span id="s-uploaded-files-and-upload-handlers"></span><span id="module-django.core.files.uploadedfile"></span><span id="uploaded-files-and-upload-handlers"></span><h1>Uploaded Files and Upload Handlers<a class="headerlink" href="#module-django.core.files.uploadedfile" title="Permalink to this headline">¶</a></h1>
<div class="section" id="s-uploaded-files">
<span id="uploaded-files"></span><h2>Uploaded files<a class="headerlink" href="#uploaded-files" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="django.core.files.uploadedfile.UploadedFile">
<em class="property">class </em><tt class="descname">UploadedFile</tt><a class="reference internal" href="../../_modules/django/core/files/uploadedfile.html#UploadedFile"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.files.uploadedfile.UploadedFile" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>During file uploads, the actual file data is stored in <a class="reference internal" href="../request-response.html#django.http.HttpRequest.FILES" title="django.http.HttpRequest.FILES"><tt class="xref py py-attr docutils literal"><span class="pre">request.FILES</span></tt></a>. Each entry in this dictionary is an
<tt class="docutils literal"><span class="pre">UploadedFile</span></tt> object (or a subclass) &#8211; a simple wrapper around an uploaded
file. You&#8217;ll usually use one of these methods to access the uploaded content:</p>
<dl class="method">
<dt id="django.core.files.uploadedfile.UploadedFile.read">
<tt class="descclassname">UploadedFile.</tt><tt class="descname">read</tt>()<a class="headerlink" href="#django.core.files.uploadedfile.UploadedFile.read" title="Permalink to this definition">¶</a></dt>
<dd><p>Read the entire uploaded data from the file. Be careful with this method:
if the uploaded file is huge it can overwhelm your system if you try to
read it into memory. You&#8217;ll probably want to use <tt class="docutils literal"><span class="pre">chunks()</span></tt> instead; see
below.</p>
</dd></dl>

<dl class="method">
<dt id="django.core.files.uploadedfile.UploadedFile.multiple_chunks">
<tt class="descclassname">UploadedFile.</tt><tt class="descname">multiple_chunks</tt>(<em>chunk_size=None</em>)<a class="headerlink" href="#django.core.files.uploadedfile.UploadedFile.multiple_chunks" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <tt class="docutils literal"><span class="pre">True</span></tt> if the uploaded file is big enough to require reading in
multiple chunks. By default this will be any file larger than 2.5 megabytes,
but that&#8217;s configurable; see below.</p>
</dd></dl>

<dl class="method">
<dt id="django.core.files.uploadedfile.UploadedFile.chunks">
<tt class="descclassname">UploadedFile.</tt><tt class="descname">chunks</tt>(<em>chunk_size=None</em>)<a class="headerlink" href="#django.core.files.uploadedfile.UploadedFile.chunks" title="Permalink to this definition">¶</a></dt>
<dd><p>A generator returning chunks of the file. If <tt class="docutils literal"><span class="pre">multiple_chunks()</span></tt> is
<tt class="docutils literal"><span class="pre">True</span></tt>, you should use this method in a loop instead of <tt class="docutils literal"><span class="pre">read()</span></tt>.</p>
<p>In practice, it&#8217;s often easiest simply to use <tt class="docutils literal"><span class="pre">chunks()</span></tt> all the time.
Looping over <tt class="docutils literal"><span class="pre">chunks()</span></tt> instead of using <tt class="docutils literal"><span class="pre">read()</span></tt> ensures that large
files don&#8217;t overwhelm your system&#8217;s memory.</p>
</dd></dl>

<p>Here are some useful attributes of <tt class="docutils literal"><span class="pre">UploadedFile</span></tt>:</p>
<dl class="attribute">
<dt id="django.core.files.uploadedfile.UploadedFile.name">
<tt class="descclassname">UploadedFile.</tt><tt class="descname">name</tt><a class="headerlink" href="#django.core.files.uploadedfile.UploadedFile.name" title="Permalink to this definition">¶</a></dt>
<dd><p>The name of the uploaded file (e.g. <tt class="docutils literal"><span class="pre">my_file.txt</span></tt>).</p>
</dd></dl>

<dl class="attribute">
<dt id="django.core.files.uploadedfile.UploadedFile.size">
<tt class="descclassname">UploadedFile.</tt><tt class="descname">size</tt><a class="headerlink" href="#django.core.files.uploadedfile.UploadedFile.size" title="Permalink to this definition">¶</a></dt>
<dd><p>The size, in bytes, of the uploaded file.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.core.files.uploadedfile.UploadedFile.content_type">
<tt class="descclassname">UploadedFile.</tt><tt class="descname">content_type</tt><a class="headerlink" href="#django.core.files.uploadedfile.UploadedFile.content_type" title="Permalink to this definition">¶</a></dt>
<dd><p>The content-type header uploaded with the file (e.g. <em class="mimetype">text/plain</em>
or <em class="mimetype">application/pdf</em>). Like any data supplied by the user, you
shouldn&#8217;t trust that the uploaded file is actually this type. You&#8217;ll still
need to validate that the file contains the content that the content-type
header claims &#8211; &#8220;trust but verify.&#8221;</p>
</dd></dl>

<dl class="attribute">
<dt id="django.core.files.uploadedfile.UploadedFile.content_type_extra">
<tt class="descclassname">UploadedFile.</tt><tt class="descname">content_type_extra</tt><a class="headerlink" href="#django.core.files.uploadedfile.UploadedFile.content_type_extra" title="Permalink to this definition">¶</a></dt>
<dd><div class="versionadded">
<span class="title">New in Django 1.7.</span> </div>
<p>A dictionary containing extra parameters passed to the <tt class="docutils literal"><span class="pre">content-type</span></tt>
header. This is typically provided by services, such as Google App Engine,
that intercept and handle file uploads on your behalf. As a result your
handler may not receive the uploaded file content, but instead a URL or
other pointer to the file. (see <a class="reference external" href="http://www.ietf.org/rfc/rfc2388.txt">RFC 2388</a> section 5.3).</p>
</dd></dl>

<dl class="attribute">
<dt id="django.core.files.uploadedfile.UploadedFile.charset">
<tt class="descclassname">UploadedFile.</tt><tt class="descname">charset</tt><a class="headerlink" href="#django.core.files.uploadedfile.UploadedFile.charset" title="Permalink to this definition">¶</a></dt>
<dd><p>For <em class="mimetype">text/*</em> content-types, the character set (i.e. <tt class="docutils literal"><span class="pre">utf8</span></tt>)
supplied by the browser. Again, &#8220;trust but verify&#8221; is the best policy here.</p>
</dd></dl>

<div class="admonition note">
<p class="first admonition-title">Note</p>
<p>Like regular Python files, you can read the file line-by-line simply by
iterating over the uploaded file:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">uploadedfile</span><span class="p">:</span>
    <span class="n">do_something_with</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
</pre></div>
</div>
<p class="last">However, <em>unlike</em> standard Python files, <a class="reference internal" href="#django.core.files.uploadedfile.UploadedFile" title="django.core.files.uploadedfile.UploadedFile"><tt class="xref py py-class docutils literal"><span class="pre">UploadedFile</span></tt></a> only
understands <tt class="docutils literal"><span class="pre">\n</span></tt> (also known as &#8220;Unix-style&#8221;) line endings. If you know
that you need to handle uploaded files with different line endings, you&#8217;ll
need to do so in your view.</p>
</div>
<p>Subclasses of <tt class="docutils literal"><span class="pre">UploadedFile</span></tt> include:</p>
<dl class="class">
<dt id="django.core.files.uploadedfile.TemporaryUploadedFile">
<em class="property">class </em><tt class="descname">TemporaryUploadedFile</tt><a class="reference internal" href="../../_modules/django/core/files/uploadedfile.html#TemporaryUploadedFile"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.files.uploadedfile.TemporaryUploadedFile" title="Permalink to this definition">¶</a></dt>
<dd><p>A file uploaded to a temporary location (i.e. stream-to-disk). This class
is used by the
<a class="reference internal" href="#django.core.files.uploadhandler.TemporaryFileUploadHandler" title="django.core.files.uploadhandler.TemporaryFileUploadHandler"><tt class="xref py py-class docutils literal"><span class="pre">TemporaryFileUploadHandler</span></tt></a>. In
addition to the methods from <a class="reference internal" href="#django.core.files.uploadedfile.UploadedFile" title="django.core.files.uploadedfile.UploadedFile"><tt class="xref py py-class docutils literal"><span class="pre">UploadedFile</span></tt></a>, it has one additional
method:</p>
</dd></dl>

<dl class="method">
<dt id="django.core.files.uploadedfile.TemporaryUploadedFile.temporary_file_path">
<tt class="descclassname">TemporaryUploadedFile.</tt><tt class="descname">temporary_file_path</tt>()<a class="reference internal" href="../../_modules/django/core/files/uploadedfile.html#TemporaryUploadedFile.temporary_file_path"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.files.uploadedfile.TemporaryUploadedFile.temporary_file_path" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the full path to the temporary uploaded file.</p>
</dd></dl>

<dl class="class">
<dt id="django.core.files.uploadedfile.InMemoryUploadedFile">
<em class="property">class </em><tt class="descname">InMemoryUploadedFile</tt><a class="reference internal" href="../../_modules/django/core/files/uploadedfile.html#InMemoryUploadedFile"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.files.uploadedfile.InMemoryUploadedFile" title="Permalink to this definition">¶</a></dt>
<dd><p>A file uploaded into memory (i.e. stream-to-memory). This class is used
by the <a class="reference internal" href="#django.core.files.uploadhandler.MemoryFileUploadHandler" title="django.core.files.uploadhandler.MemoryFileUploadHandler"><tt class="xref py py-class docutils literal"><span class="pre">MemoryFileUploadHandler</span></tt></a>.</p>
</dd></dl>

</div>
<div class="section" id="s-module-django.core.files.uploadhandler">
<span id="s-built-in-upload-handlers"></span><span id="module-django.core.files.uploadhandler"></span><span id="built-in-upload-handlers"></span><h2>Built-in upload handlers<a class="headerlink" href="#module-django.core.files.uploadhandler" title="Permalink to this headline">¶</a></h2>
<p>Together the <a class="reference internal" href="#django.core.files.uploadhandler.MemoryFileUploadHandler" title="django.core.files.uploadhandler.MemoryFileUploadHandler"><tt class="xref py py-class docutils literal"><span class="pre">MemoryFileUploadHandler</span></tt></a> and
<a class="reference internal" href="#django.core.files.uploadhandler.TemporaryFileUploadHandler" title="django.core.files.uploadhandler.TemporaryFileUploadHandler"><tt class="xref py py-class docutils literal"><span class="pre">TemporaryFileUploadHandler</span></tt></a> provide Django&#8217;s default file upload
behavior of reading small files into memory and large ones onto disk. They
are located in <tt class="docutils literal"><span class="pre">django.core.files.uploadhandler</span></tt>.</p>
<dl class="class">
<dt id="django.core.files.uploadhandler.MemoryFileUploadHandler">
<em class="property">class </em><tt class="descname">MemoryFileUploadHandler</tt><a class="reference internal" href="../../_modules/django/core/files/uploadhandler.html#MemoryFileUploadHandler"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.files.uploadhandler.MemoryFileUploadHandler" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>File upload handler to stream uploads into memory (used for small files).</p>
<dl class="class">
<dt id="django.core.files.uploadhandler.TemporaryFileUploadHandler">
<em class="property">class </em><tt class="descname">TemporaryFileUploadHandler</tt><a class="reference internal" href="../../_modules/django/core/files/uploadhandler.html#TemporaryFileUploadHandler"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.files.uploadhandler.TemporaryFileUploadHandler" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Upload handler that streams data into a temporary file using
<a class="reference internal" href="#django.core.files.uploadedfile.TemporaryUploadedFile" title="django.core.files.uploadedfile.TemporaryUploadedFile"><tt class="xref py py-class docutils literal"><span class="pre">TemporaryUploadedFile</span></tt></a>.</p>
</div>
<div class="section" id="s-writing-custom-upload-handlers">
<span id="s-custom-upload-handlers"></span><span id="writing-custom-upload-handlers"></span><span id="custom-upload-handlers"></span><h2>Writing custom upload handlers<a class="headerlink" href="#writing-custom-upload-handlers" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="django.core.files.uploadhandler.FileUploadHandler">
<em class="property">class </em><tt class="descname">FileUploadHandler</tt><a class="reference internal" href="../../_modules/django/core/files/uploadhandler.html#FileUploadHandler"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.files.uploadhandler.FileUploadHandler" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>All file upload handlers should be subclasses of
<tt class="docutils literal"><span class="pre">django.core.files.uploadhandler.FileUploadHandler</span></tt>. You can define upload
handlers wherever you wish.</p>
<div class="section" id="s-required-methods">
<span id="required-methods"></span><h3>Required methods<a class="headerlink" href="#required-methods" title="Permalink to this headline">¶</a></h3>
<p>Custom file upload handlers <strong>must</strong> define the following methods:</p>
<dl class="method">
<dt id="django.core.files.uploadhandler.FileUploadHandler.receive_data_chunk">
<tt class="descclassname">FileUploadHandler.</tt><tt class="descname">receive_data_chunk</tt>(<em>raw_data</em>, <em>start</em>)<a class="reference internal" href="../../_modules/django/core/files/uploadhandler.html#FileUploadHandler.receive_data_chunk"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.files.uploadhandler.FileUploadHandler.receive_data_chunk" title="Permalink to this definition">¶</a></dt>
<dd><p>Receives a &#8220;chunk&#8221; of data from the file upload.</p>
<p><tt class="docutils literal"><span class="pre">raw_data</span></tt> is a byte string containing the uploaded data.</p>
<p><tt class="docutils literal"><span class="pre">start</span></tt> is the position in the file where this <tt class="docutils literal"><span class="pre">raw_data</span></tt> chunk
begins.</p>
<p>The data you return will get fed into the subsequent upload handlers&#8217;
<tt class="docutils literal"><span class="pre">receive_data_chunk</span></tt> methods. In this way, one handler can be a
&#8220;filter&#8221; for other handlers.</p>
<p>Return <tt class="docutils literal"><span class="pre">None</span></tt> from <tt class="docutils literal"><span class="pre">receive_data_chunk</span></tt> to short-circuit remaining
upload handlers from getting this chunk. This is useful if you&#8217;re
storing the uploaded data yourself and don&#8217;t want future handlers to
store a copy of the data.</p>
<p>If you raise a <tt class="docutils literal"><span class="pre">StopUpload</span></tt> or a <tt class="docutils literal"><span class="pre">SkipFile</span></tt> exception, the upload
will abort or the file will be completely skipped.</p>
</dd></dl>

<dl class="method">
<dt id="django.core.files.uploadhandler.FileUploadHandler.file_complete">
<tt class="descclassname">FileUploadHandler.</tt><tt class="descname">file_complete</tt>(<em>file_size</em>)<a class="reference internal" href="../../_modules/django/core/files/uploadhandler.html#FileUploadHandler.file_complete"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.files.uploadhandler.FileUploadHandler.file_complete" title="Permalink to this definition">¶</a></dt>
<dd><p>Called when a file has finished uploading.</p>
<p>The handler should return an <tt class="docutils literal"><span class="pre">UploadedFile</span></tt> object that will be stored
in <tt class="docutils literal"><span class="pre">request.FILES</span></tt>. Handlers may also return <tt class="docutils literal"><span class="pre">None</span></tt> to indicate that
the <tt class="docutils literal"><span class="pre">UploadedFile</span></tt> object should come from subsequent upload handlers.</p>
</dd></dl>

</div>
<div class="section" id="s-optional-methods">
<span id="optional-methods"></span><h3>Optional methods<a class="headerlink" href="#optional-methods" title="Permalink to this headline">¶</a></h3>
<p>Custom upload handlers may also define any of the following optional methods or
attributes:</p>
<dl class="attribute">
<dt id="django.core.files.uploadhandler.FileUploadHandler.chunk_size">
<tt class="descclassname">FileUploadHandler.</tt><tt class="descname">chunk_size</tt><a class="headerlink" href="#django.core.files.uploadhandler.FileUploadHandler.chunk_size" title="Permalink to this definition">¶</a></dt>
<dd><p>Size, in bytes, of the &#8220;chunks&#8221; Django should store into memory and feed
into the handler. That is, this attribute controls the size of chunks
fed into <tt class="docutils literal"><span class="pre">FileUploadHandler.receive_data_chunk</span></tt>.</p>
<p>For maximum performance the chunk sizes should be divisible by <tt class="docutils literal"><span class="pre">4</span></tt> and
should not exceed 2 GB (2<sup>31</sup> bytes) in size. When there are
multiple chunk sizes provided by multiple handlers, Django will use the
smallest chunk size defined by any handler.</p>
<p>The default is 64*2<sup>10</sup> bytes, or 64 KB.</p>
</dd></dl>

<dl class="method">
<dt id="django.core.files.uploadhandler.FileUploadHandler.new_file">
<tt class="descclassname">FileUploadHandler.</tt><tt class="descname">new_file</tt>(<em>field_name</em>, <em>file_name</em>, <em>content_type</em>, <em>content_length</em>, <em>charset</em>, <em>content_type_extra</em>)<a class="reference internal" href="../../_modules/django/core/files/uploadhandler.html#FileUploadHandler.new_file"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.files.uploadhandler.FileUploadHandler.new_file" title="Permalink to this definition">¶</a></dt>
<dd><p>Callback signaling that a new file upload is starting. This is called
before any data has been fed to any upload handlers.</p>
<p><tt class="docutils literal"><span class="pre">field_name</span></tt> is a string name of the file <tt class="docutils literal"><span class="pre">&lt;input&gt;</span></tt> field.</p>
<p><tt class="docutils literal"><span class="pre">file_name</span></tt> is the unicode filename that was provided by the browser.</p>
<p><tt class="docutils literal"><span class="pre">content_type</span></tt> is the MIME type provided by the browser &#8211; E.g.
<tt class="docutils literal"><span class="pre">'image/jpeg'</span></tt>.</p>
<p><tt class="docutils literal"><span class="pre">content_length</span></tt> is the length of the image given by the browser.
Sometimes this won&#8217;t be provided and will be <tt class="docutils literal"><span class="pre">None</span></tt>.</p>
<p><tt class="docutils literal"><span class="pre">charset</span></tt> is the character set (i.e. <tt class="docutils literal"><span class="pre">utf8</span></tt>) given by the browser.
Like <tt class="docutils literal"><span class="pre">content_length</span></tt>, this sometimes won&#8217;t be provided.</p>
<p><tt class="docutils literal"><span class="pre">content_type_extra</span></tt> is extra information about the file from the
<tt class="docutils literal"><span class="pre">content-type</span></tt> header. See <a class="reference internal" href="#django.core.files.uploadedfile.UploadedFile.content_type_extra" title="django.core.files.uploadedfile.UploadedFile.content_type_extra"><tt class="xref py py-attr docutils literal"><span class="pre">UploadedFile.content_type_extra</span></tt></a>.</p>
<p>This method may raise a <tt class="docutils literal"><span class="pre">StopFutureHandlers</span></tt> exception to prevent
future handlers from handling this file.</p>
<div class="versionadded">
<span class="title">New in Django 1.7:</span> <p>The <tt class="docutils literal"><span class="pre">content_type_extra</span></tt> parameter was added.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="django.core.files.uploadhandler.FileUploadHandler.upload_complete">
<tt class="descclassname">FileUploadHandler.</tt><tt class="descname">upload_complete</tt>()<a class="reference internal" href="../../_modules/django/core/files/uploadhandler.html#FileUploadHandler.upload_complete"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.files.uploadhandler.FileUploadHandler.upload_complete" title="Permalink to this definition">¶</a></dt>
<dd><p>Callback signaling that the entire upload (all files) has completed.</p>
</dd></dl>

<dl class="method">
<dt id="django.core.files.uploadhandler.FileUploadHandler.handle_raw_input">
<tt class="descclassname">FileUploadHandler.</tt><tt class="descname">handle_raw_input</tt>(<em>input_data</em>, <em>META</em>, <em>content_length</em>, <em>boundary</em>, <em>encoding</em>)<a class="reference internal" href="../../_modules/django/core/files/uploadhandler.html#FileUploadHandler.handle_raw_input"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.files.uploadhandler.FileUploadHandler.handle_raw_input" title="Permalink to this definition">¶</a></dt>
<dd><p>Allows the handler to completely override the parsing of the raw
HTTP input.</p>
<p><tt class="docutils literal"><span class="pre">input_data</span></tt> is a file-like object that supports <tt class="docutils literal"><span class="pre">read()</span></tt>-ing.</p>
<p><tt class="docutils literal"><span class="pre">META</span></tt> is the same object as <tt class="docutils literal"><span class="pre">request.META</span></tt>.</p>
<p><tt class="docutils literal"><span class="pre">content_length</span></tt> is the length of the data in <tt class="docutils literal"><span class="pre">input_data</span></tt>. Don&#8217;t
read more than <tt class="docutils literal"><span class="pre">content_length</span></tt> bytes from <tt class="docutils literal"><span class="pre">input_data</span></tt>.</p>
<p><tt class="docutils literal"><span class="pre">boundary</span></tt> is the MIME boundary for this request.</p>
<p><tt class="docutils literal"><span class="pre">encoding</span></tt> is the encoding of the request.</p>
<p>Return <tt class="docutils literal"><span class="pre">None</span></tt> if you want upload handling to continue, or a tuple of
<tt class="docutils literal"><span class="pre">(POST,</span> <span class="pre">FILES)</span></tt> if you want to return the new data structures suitable
for the request directly.</p>
</dd></dl>

</div>
</div>
</div>


          </div>
        </div>
      </div>
      
        
          <div class="yui-b" id="sidebar">
            
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../../contents.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Uploaded Files and Upload Handlers</a><ul>
<li><a class="reference internal" href="#uploaded-files">Uploaded files</a></li>
<li><a class="reference internal" href="#module-django.core.files.uploadhandler">Built-in upload handlers</a></li>
<li><a class="reference internal" href="#writing-custom-upload-handlers">Writing custom upload handlers</a><ul>
<li><a class="reference internal" href="#required-methods">Required methods</a></li>
<li><a class="reference internal" href="#optional-methods">Optional methods</a></li>
</ul>
</li>
</ul>
</li>
</ul>

  <h3>Browse</h3>
  <ul>
    
      <li>Prev: <a href="storage.html">File storage API</a></li>
    
    
      <li>Next: <a href="../forms/index.html">Forms</a></li>
    
  </ul>
  <h3>You are here:</h3>
  <ul>
      <li>
        <a href="../../index.html">Django 1.7.8.dev20150401230226 documentation</a>
        
          <ul><li><a href="../index.html">API Reference</a>
        
          <ul><li><a href="index.html">File handling</a>
        
        <ul><li>Uploaded Files and Upload Handlers</li></ul>
        </li></ul></li></ul>
      </li>
  </ul>

  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../../_sources/ref/files/uploads.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
              <h3>Last update:</h3>
              <p class="topless">Apr 02, 2015</p>
          </div>
        
      
    </div>

    <div id="ft">
      <div class="nav">
    &laquo; <a href="storage.html" title="File storage API">previous</a>
     |
    <a href="../index.html" title="API Reference" accesskey="U">up</a>
   |
    <a href="../forms/index.html" title="Forms">next</a> &raquo;</div>
    </div>
  </div>

      <div class="clearer"></div>
    </div>
  </body>
</html>